// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UcDbListBase.cs" company="SmartPlan">
//   SmartPlan 2011
// </copyright>
// <summary>
//   Summary description for UcDbListBase.
// </summary>
// --------------------------------------------------------------------------------------------------------------------


namespace DbDiff.WinClient.Forms.DbItems
{
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;
    using Common.Helper;

    /// <summary>
    /// User control list base
    /// </summary>
    public class UcDbListBase : UserControl
    {
        #region Events & delegates

        #region Delegates

        /// <summary>
        /// The on row click event handler.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The event args
        /// </param>
        public delegate void OnRowClickEventHandler(object sender, RowClickEventArgs e);

        #endregion

        /// <summary>
        /// The on row select.
        /// </summary>
        public event OnRowClickEventHandler OnRowSelect;

        /// <summary>
        /// The on row double click.
        /// </summary>
        public event OnRowClickEventHandler OnRowDoubleClick;

        #endregion Events & delegates

        #region Fields & properties

        /// <summary>
        /// The _database index.
        /// </summary>
        protected int _databaseIndex;

        /// <summary>
        /// The _item type info.
        /// </summary>
        protected DatabaseObjectTypes _itemTypeInfo;

        /// <summary>
        /// The _title.
        /// </summary>
        protected string _title;

        /// <summary>
        /// The lbl title.
        /// </summary>
        protected Label lblTitle;

        /// <summary>
        /// Gets ItemTypeInfo.
        /// </summary>
        public DatabaseObjectTypes ItemTypeInfo
        {
            get { return this._itemTypeInfo; }
        }

        /// <summary>
        /// Gets DatabaseIndex.
        /// </summary>
        public int DatabaseIndex
        {
            get { return this._databaseIndex; }
        }

        /// <summary>
        /// Gets or sets Title.
        /// </summary>
        public string Title
        {
            get
            {
                return this._title;
            }

            set
            {
                this._title = value;
                this.lblTitle.Text = this._title;
            }
        }

        #endregion Fields & properties

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="UcDbListBase"/> class.
        /// </summary>
        public UcDbListBase()
        {
            // This call is required by the Windows.Forms Form Designer.
            this.InitializeComponent();
            this._databaseIndex = -1;
            this._title = string.Empty;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UcDbListBase"/> class.
        /// </summary>
        /// <param name="title">
        /// The title.
        /// </param>
        /// <param name="contextMenu">
        /// The context menu.
        /// </param>
        /// <param name="databaseIndex">
        /// The database index.
        /// </param>
        public UcDbListBase(string title, ContextMenu contextMenu, int databaseIndex)
        {
            // This call is required by the Windows.Forms Form Designer.
            this.InitializeComponent();
            this.ContextMenu = contextMenu;
            this._databaseIndex = databaseIndex;
            this._title = title;
        }

        #endregion Constructors

        #region SetData

        /// <summary>
        /// The set data.
        /// </summary>
        /// <param name="data">
        /// The data.
        /// </param>
        /// <param name="itemTypeInfo">
        /// The item type info.
        /// </param>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public virtual void SetData(DataTable data, DatabaseObjectTypes itemTypeInfo)
        {
            throw new NotImplementedException(
                "ERROR: UcDbListBase.SetData(DataTable data, dbObjectsTable itemTypeInfo) is not implemented!");
        }

        /// <summary>
        /// The set data.
        /// </summary>
        /// <param name="data">
        /// The data.
        /// </param>
        /// <param name="itemTypeInfo">
        /// The item type info.
        /// </param>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public virtual void SetData(DataView data, DatabaseObjectTypes itemTypeInfo)
        {
            throw new NotImplementedException(
                "ERROR: UcDbListBase.SetData(DataView data, dbObjectsTable itemTypeInfo) is not implemented!");
        }

        /// <summary>
        /// The set data.
        /// </summary>
        /// <param name="data">
        /// The data.
        /// </param>
        /// <param name="filterExpression">
        /// The filter expression.
        /// </param>
        /// <param name="itemTypeInfo">
        /// The item type info.
        /// </param>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public virtual void SetData(DataTable data, string filterExpression, DatabaseObjectTypes itemTypeInfo)
        {
            throw new NotImplementedException(
                "ERROR: UcDbListBase.SetData(DataTable data, string filterExpression, dbObjectsTable itemTypeInfo) is not implemented!");
        }

        #endregion SetData

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">
        /// The disposing.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
            }

            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify 
        ///   the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.lblTitle = new Label();
            this.SuspendLayout();

// lblTitle
            this.lblTitle.BackColor = System.Drawing.SystemColors.ActiveCaption;
            this.lblTitle.Dock = System.Windows.Forms.DockStyle.Top;
            this.lblTitle.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
            this.lblTitle.Location = new Point(0, 0);
            this.lblTitle.Name = "lblTitle";
            this.lblTitle.Size = new Size(544, 23);
            this.lblTitle.TabIndex = 0;
            this.lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;

// UcDbListBase
            this.Controls.Add(this.lblTitle);
            this.Name = "UcDbListBase";
            this.Size = new Size(544, 352);
            this.ResumeLayout(false);
        }

        #endregion

        #region Events

        /// <summary>
        /// The fire row select event.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The event args
        /// </param>
        protected void FireRowSelectEvent(object sender, RowClickEventArgs e)
        {
            if (this.OnRowSelect != null)
            {
                this.OnRowSelect(sender, e);
            }
        }

        /// <summary>
        /// The fire row double click event.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The event args
        /// </param>
        protected void FireRowDoubleClickEvent(object sender, RowClickEventArgs e)
        {
            if (this.OnRowDoubleClick != null)
            {
                this.OnRowDoubleClick(sender, e);
            }
        }

        #endregion Events
    }
}
